Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SITL: add basic support for visual odometry simulation #12414

Closed
wants to merge 3 commits into from

Conversation

thien94
Copy link
Contributor

@thien94 thien94 commented Sep 26, 2019

With many new developments for visual odometry (VO), it would be very helpful to have SITL support so that we can replicate and investigate issues that happen in various scenarios. This PR attempts to provide a simulated VO system onboard the vehicle.

The normal operation of the simulated VO system is:

  • Start the simulation with VO system attached to UARTB (similar to Vicon):
./Tools/autotest/sim_vehicle.py -v ArduCopter --gdb --debug -A "--uartB=sim:viso:" --map --console
  • Enable with param set SIM_VISO_ENABLE 1. VO system always starts at (0, 0, 0) and have a heading of 0. Upon enabling the simulated VO will start sending VISION_POSITION_ESTIMATE message to the vehicle.
  • Disable with param set SIM_VISO_ENABLE 0, which would stop sending the message immediately. When the system is enabled again, the original position and heading are reset.

In this first PR, 3 of the most frequent kinds of issues encountered with VO is simulated:

  1. Scale. The position from odometry might be off, in some cases up to 20-30%, of the true value.
    -- Usage: scale can be modified with SIM_VISO_SCALE. For example, param set SIM_VISO_SCALE 0.9 will make moving 1m in any axis into 0.9m in reported position in the message.
  2. Divergence. When divergence occurs, the position will exponentially or gradually increase to infinity. In this PR we shall implement the former.
    -- Usage: first define divergence rate, e.g. param set SIM_VISO_DIVRATE 1.01 is 1% increase of position in each step. Start the divergence with param set SIM_VISO_ERROR 1.
  3. Jumping: In most SLAM systems, when loop closure / relocalization function is enabled, the position might jump erratically at certain locations in the map. For now, we simulate this as a jump of 1m in all xyz directions.
    -- Usage: start the jump with param set SIM_VISO_ERROR 1. Set the param to 0 then 1 to jump again.

This is by no means a thorough simulation of VO, but I hope this can be a stepping stone for upcoming developments in the codebase.


Some observations:

  • Compared with the current SIM_Vicon, which also utilizes the VISION_POSITION_ESTIMATE message, some of the most noticable differences are:
Feature SIM_Vicon SIM_VisualOdometry
Position type Absolute (fixed world frame) Relative (world frame is set at first camera frame)
Possible MAVLink messages VISION_POSITION_ESTIMATE, VICON_POSITION_ESTIMATE VISION_POSITION_ESTIMATE, VISION_SPEED_ESTIMATE, ODOMETRY, VISION_POSITION_DELTA
Potential issues Occlusion (temporarily lost of data) Scale offset, divergence, tracking lost, jumping (due to loop closure or relocalizatoin), drift, etc. each with different variations

Thus, I believe there would be more room for future developments by separating the two types instead of building on top of the existing SIM_Vicon.

  • In my SITL tests, most of the times when divergence occurs the copter would keep moving a bit before EKF Variance error appears, subsequently it would switch to land.

  • Jumping of 1m when the vehicle is moving does not seem to have any effect, but when the vehicle is stationary in some cases I encounter EKF variance error.

  • With COMPASS_USE enable, the heading will start at some direction of compass, then slowly moves to 0, similar to what I observe with real copter. In my tests, I usually disable all compass with param set COMPASS_USE 0 as well as COMPASS_USE2 and COMPASS_USE3.

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add at least one autotest which tests this simulation.

libraries/SITL/SIM_VisualOdometry.h Outdated Show resolved Hide resolved
@tridge
Copy link
Contributor

tridge commented Oct 8, 2019

I do like the simulated errors, very useful, but I think we could have SIM_* options on the existing vicon sim to allow for both to share the same code. As long as the errors are off by default then the two systems are so similar that having a separate implementation doesn't look like a good idea

@thien94
Copy link
Contributor Author

thien94 commented Oct 9, 2019

@tridge the two systems do behave similarly in normal operating scenarios. I think separating the two classes for VO and vicon would be beneficial and less confusing for future developments.
Should I bring the error cases (scale, divergence and jump) to the Vicon class in a separate PR? Then this PR can be dismissed for now.

@peterbarker
Copy link
Contributor

@thien94 having those error cases in the normal vicon sounds good, if you're still interested.

This is now conflicting rather significantly, so I think I might close it.

Apologies we didn't get back to this....

@peterbarker peterbarker closed this Feb 4, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants